﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SpaceGame
{
    public class Wraith : PlayerSpaceShip
    {

        public Wraith(Position topLeft)
            : base(topLeft, new char[,] { {'I', ' ', ' '}, {'I', '}', '>'}, {'I', ' ', ' '}})
        {
            char[,] secondFrame =
            {
                {'I', ' ', ' '},
                {'I', '=', (char)16},
                {'I', ' ', ' '}
            };
            this.AddFrame(secondFrame);
        }

        public override void UpdatePosition()
        {
            if (left == true)
            {
                this.Direction += new Position(0, -1);
                left = false;
            }
            else if (right == true)
            {
                this.Direction += new Position(0, 1);
                right = false;
            }
            else if (top == true)
            {
                this.Direction += new Position(-1, 0);
                top = false;
            }
            else if (down == true)
            {
                this.Direction += new Position(1, 0);
                down = false;
            }

            RestrainMovement();

            //this.Direction = new Position(0, 0);    // no acceleration
        }
        
        public override IEnumerable<GameObject> CreateObjects()
        {
            if (isShooting)
            {
                isShooting = false;
                int height = this.Image.GetLength(0);
                int width = this.Image.GetLength(1);

                return new List<GameObject>
                {
                    new Bullet(new Position(this.TopLeft.Row + height/2, this.TopLeft.Col + width/2 + 1),
                        new char[,] { { '-', '-'} }, 1, new Position(0, 2)),
                };
            }
            return base.CreateObjects();
        }
    }
}
